package Main;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;


public class ButtonPanel extends JPanel{

	private int y;
	private JButton btn;
	private JPanel parent;
	private CardLayout cards;
	public ButtonPanel(FileReader fr, final JPanel parent, final CardLayout cards, final JTable ex){
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.parent=parent;
		this.cards=cards;
		JButton[] b = new JButton[fr.getProcess().size()];
		for(y=0; y<fr.getProcess().size(); y++){
			b[y]=new JButton("P"+(y+1)+"");
			b[y].addActionListener(
			
					new ActionListener(){

						@Override
						public void actionPerformed(ActionEvent a) {
							// TODO Auto-generated method stub
							int k=Integer.parseInt(a.getActionCommand().substring(1));
							ex.revalidate();
							cards.show(parent, k-1+"");
							
						}
						
					}
			);
			this.add(b[y]);
			
		}
		
	}
	}
